package hive;

import java.sql.*;

public class HiveTest {
    public static void main(String[] args) throws Exception {
        Class.forName("org.apache.hive.jdbc.HiveDriver");
        Connection con = DriverManager.getConnection("jdbc:hive2://master:10000/myhive");
        Statement statement = con.createStatement();
        String sql="select * from students";
        ResultSet rs = statement.executeQuery(sql);
        while (rs.next()){
            String id = rs.getString("id");
            String name = rs.getString("name");
            String age = rs.getString("age");
            String sex = rs.getString("sex");
            String clazz = rs.getString("clazz");
            System.out.println(id+"--"+name+"--"+age+"--"+sex+"--"+clazz);

        }
        rs.close();
        statement.close();
        con.close();

    }
}
